<template>
    <div id="Feedback">
        <NavBarTitle :NavBarTitle="NavBarTitle"/>
        <van-form @submit="onSubmit">
            <div style="width:100%" class="flex jCenter">
                <div style="width: 93.6%">
                    <van-field
                            v-model="message"
                            rows="1"
                            name="message"
                            type="textarea"
                            clearable
                            placeholder="请输入反馈内容,我们会为您更好得服务"
                    />
                </div>
            </div>
            <div style="margin: 82px 12px 0 12px;">
                <van-button block type="info" native-type="submit" color="#0fa0a0"
                            style="font-size:18px;border-radius: 5px">
                    提交
                </van-button>
            </div>
        </van-form>
    </div>

</template>

<script>
    import NavBarTitle from 'components/NavBarTitle.vue'

    export default {
        data() {
            return {
                NavBarTitle: '意见反馈',
                message: '',
            }
        },
        components: {
            NavBarTitle
        },
        methods: {
            onSubmit(values) {
                console.log(values);
                let data = {
                    token: this.$store.state.token,
                    content: values.message
                };
                this.$axios.post(this.$index+this.$api.user.addfeedback,this.$Qs.stringify(data))
                    .then((res) => {
                        console.log(res);
                        if(res.data.flag){
                            this.$toast.success({
                                message: res.data.msg,
                                duration: 1000,
                                onClose: () => {
                                    this.$router.replace('/user');
                                }
                            });
                        }else {
                            this.$toast(res.data.msg);
                        }
                    }).catch((err) => {
                    console.log(err);
                })
            }
        },
        beforeMount() {

        }
    }
</script>

<style scoped>
    /deep/.van-cell{
        height: 180px;
    }
</style>